
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 3
 * @Author : WangRuoyu 
 * @Date : 2023/5/11 15:59
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

typedef long long LL;
int const N = 5010;

struct record {
    int type;
    double p;
    int s;
} d[N];

int main() {
    string type;
    int cnt = 0;
    while (cin >> type) {
        cnt++;
        if (type == "buy") {
            d[cnt].type = -1;
            cin >> d[cnt].p;
            cin >> d[cnt].s;
        } else if (type == "sell") {
            d[cnt].type = 1;
            cin >> d[cnt].p;
            cin >> d[cnt].s;
        } else {
            int id;
            cin >> id;
            d[id].type = 0;
        }
    }


    double resp = 0;
    LL ress = 0;
    for (int i = 1; i <= cnt; ++i) {
        if (d[i].type) {
            double p = d[i].p;
            LL s1 = 0;
            LL s2 = 0;
            for (int j = 1; j <= cnt; ++j) {
                if (d[i].type) {
                    if (d[j].type == -1 && d[j].p >= p) s1 += d[j].s;
                    else if (d[j].type == 1 && d[j].p <= p) s2 += d[j].s;
                }
            }
            LL t = min(s1, s2);
            if (t > ress || t == ress && p > resp) {
                ress = t;
                resp = p;
            }
        }
    }

    printf("%.2lf %lld\n", resp, ress);

    return 0;
}